<template>
	<view class="search">
		<view class="top">
				<input type="text" class="inp" placeholder="搜索商品" v-model="keyword"/>
				<button class="btn" @click="SearchFn()">搜索</button>
		</view>
		<view class="bottom">
			<view class="shop_opt" v-for="item in shop_list" @click="goDetail(item.pid)">
			    <image class="shop_img" :src="item.smallImg" mode="widthFix"/>
			    <view class="shop_right">
			        <view class="shop_h">
						<text>{{item.name}}</text>
			        </view>
			        <view class="shop_p">
						<text>{{item.desc}}</text>
			        </view>
			        <view class="shop_price">
						<view>
							<text class="price">{{item.price}}</text>
							<text>预估到手</text>
						</view>
						<view class="shop_jia">+</view>
			        </view>
			    </view>
			</view>
		</view>
	</view>
</template>

<script>
	import { searchFn } from '../../api/index.js';
	export default {
		data() {
			return {
				keyword:"",
				shop_list:[]
			}
		},
		methods: {
			async SearchFn(){
				await searchFn({
					appkey:"U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA=",
					name:this.keyword
				})
				.then(
					content=>{
						console.log(content);
						let {code,result,msg} = content;
						if(code == 'Q001'){
							this.shop_list = result;
						}
					}
				)
			},
			goDetail(id){
				uni.navigateTo({
					url:'/pages/detail/detail?pid='+id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.search{
		width: 100%;
		height: 100%;
		.top{
			height: 40px;
			display: flex;
			padding: 20rpx;
			.inp{
				width: calc(100% - 140rpx);
				height: 80rpx;
				box-sizing: border-box;
				border: 1px solid #252973;
				padding-left: 40rpx;
				border-top-left-radius: 40rpx;
				border-bottom-left-radius: 40rpx;
			}
			.btn{
				width: 140rpx;
				height: 80rpx;
				margin: 0;
				padding: 0;
				line-height: 80rpx;
				background-color: #252973;
				color: white;
				border-radius: 0;
				font-size: 16px;
				border-top-right-radius: 40rpx;
				border-bottom-right-radius: 40rpx;
			}
		}
		.bottom{
			margin: 40rpx 20rpx;
			.shop_opt{
				width: 100%;
				height: 400rpx;
				display: flex;
				.shop_img{
					width: 50%;
				}
				.shop_right{
					width: 50%;
					padding: 10rpx;
					.shop_h{
						font-size: 46rpx;
						font-weight: bolder;
					}
					.shop_p{
						font-size: 24rpx;
						color: rgb(182, 174, 174);
						margin-top: 10rpx;
						margin-bottom: 20rpx;
						height: 210rpx;
						/*设置为弹性盒子*/
						display:-webkit-box;
						/* 表示几行后超出隐藏 */
						-webkit-line-clamp:7;
						overflow: hidden;
						text-overflow:ellipsis;
						-webkit-box-orient:vertical;
					}
					.shop_price{
						font-size: 30rpx;
						color: red;
						display: flex;
						justify-content: space-between;
						.price{
							font-size: 40rpx;
						}
							
						.shop_jia{
							font-size: 50rpx;
							background-color: #252973;
							width: 60rpx;
							height: 60rpx;
							border-radius: 50%;
							text-align: center;
							line-height: 50rpx;
							color: white;
						}
					}
				}
			}
		}
	}
</style>
